//============================================================================
// Copyright (C) 2010 Brett R. Jones
// All Rights Reserved
//
// You may redistribute and/or modify for non commercial and commercial uses
// provided this copyright notice remains in place and is not modified
//
// This code is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//
// brettjones1900@gmail.com
// http://www.p2panarchy.com
//============================================================================

#include "DtwGame.h"


//------------------------------------------------------------------------------
//=== constructor ===//
DtwStateCutScene::DtwStateCutScene()
	: m_poGameMgr(0)
{
}
//------------------------------------------------------------------------------
//=== destructor ===//
DtwStateCutScene::~DtwStateCutScene()
{
}
//------------------------------------------------------------------------------
//=== state overrides ===//
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
//! startup
RCODE DtwStateCutScene::GameStateStartup( VxIrrBase * poIrrBase )
{
	GameStateBase::GameStateStartup( poIrrBase );
	m_poGameMgr = g_poGameMgr;
	log_msg( 0, "DtwStateCutScene::GameStateStartup:\n" );

#ifdef WIN_PLATFORM
	// have not implemented movie player for windows yet
	// just skip to next state
	CutSceneCompleted();
#endif //WIN_PLATFORM
	// set start time seconds
	m_u32CutSceneStartTime = g_u32SysTimeSec;
	g_oSndMgr.MoviePlay( "explodeplanet.mp4" );
	return 0;
}


//------------------------------------------------------------------------------
//! shutdown
void DtwStateCutScene::GameStateShutdown( void )
{
}
//------------------------------------------------------------------------------
// update timed elements
RCODE DtwStateCutScene::GameStateUpdate( U32 u32FrameTimeMs ) 
{
	if( ( g_u32SysTimeSec - m_u32CutSceneStartTime ) > 8 )
	{
		// cut scene has played
		CutSceneCompleted();
	}
	return 0;
}
//----------------------------------------------------------------------------
//! called when application is about to sleep
RCODE DtwStateCutScene::GameStateAppSleep( void )
{
	return 0;
}
//------------------------------------------------------------------------------
//! called when application is resuming from sleep.. app must reload textures etc
RCODE DtwStateCutScene::GameStateAppResume( U32 u32FrameTimeMs )
{
	return 0;
}
//----------------------------------------------------------------------------
//! do cut scene completed action
void DtwStateCutScene::CutSceneCompleted( void )
{
	// 
	// video surface is lost when cut scene is played.. 
	m_poGameMgr->IrrBaseRestart();
	DtwStateMenu * poMenuState = new DtwStateMenu();
	m_poGameMgr->m_poNewState = poMenuState;
	if( g_HighScoresImp.IsHighScore( m_poIrrBase->m_iGameLevel, m_poIrrBase->m_iGameScore, m_poIrrBase->m_iGameTime ) )
	{
		poMenuState->m_eCurMenuState = eMenuStateInitGameOverHighScore;
	}
	else
	{
		poMenuState->m_eCurMenuState = eMenuStateInitGameOver;
	}
}




